const axios = require('axios');

module.exports = {
    devServer: {
        port: 3000,
        // https: true,
        //webpack.config.js
        before (app) {
            app.get('/api/getDiscList', function (req, res) {
                var url = 'https://c.y.qq.com/splcloud/fcgi-bin/fcg_get_diss_by_tag.fcg'
                axios.get(url, {
                    headers: {
                        referer: 'https://c.y.qq.com/',
                        host: 'c.y.qq.com'
                    },
                    params: req.query
                }).then((response) => {
                    res.json(response.data)
                }).catch((e) => {
                    console.log(e)
                })
            })
            app.get('/api/getMusic', function (req, res) {
                var url = 'https://u.y.qq.com/cgi-bin/musicu.fcg'
                axios.get(url, {
                    headers: {
                        referer: 'https://u.y.qq.com/',
                        host: 'u.y.qq.com'
                    },
                    params: req.query
                }).then((response) => {
                    res.json(response.data)
                }).catch((e) => {
                    console.log(e)
                })
            })
        },
        // proxy: {
        //     '/qq': {
        //         target: "https://u.y.qq.com/cgi-bin/musicu.fcg?-=recom8349887828734386&g_tk=5381&loginUin=0&hostUin=0&format=json&inCharset=utf8&outCharset=utf-8&notice=0&platform=yqq.json&needNewCode=0&data=%7B%22comm%22%3A%7B%22ct%22%3A24%7D%2C%22new_song%22%3A%7B%22module%22%3A%22newsong.NewSongServer%22%2C%22method%22%3A%22get_new_song_info%22%2C%22param%22%3A%7B%22type%22%3A2%7D%7D%7D",
        //         changeOrigin: true,
        //         secure: false
        //     }
        // }
    }
}